Controller
<?php
public function indexAction()
{
$item = new \stdClass();
$item->var1 = '1';
$item->var2 = '2';
$item->var4 = '3';
$test = array(
'item' => $item
);
$this->view->setVars(array(
'test' => $test
));
}
Volt template
{{ dump(test['item'].var1) }}
Code generated in cache
<?php echo var_dump(($test['item'])->var1); ?>
Volt template
{{ test['item'].var1 }}
Code generated in cache
<?php echo ($test['item'])->var1; ?>
I get ( ! ) Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in /work/nested-set/tree/app/cache/_work_nested-set_tree_app_views_index_index.volt.php on line 26
In Controller all works as usual
var_dump($test['item']->var1); //1
My question is there is a bug or my mistake?
This structure works as expected
{% for t in tree %}
{% set a = t["item"] %}
{{ a.getName() }}
{% endfor %}
But why do I have create another variable for getting object property?
Thanks